<!--
 * @Author: your name
 * @Date: 2021-09-06 18:38:42
 * @LastEditTime: 2021-09-12 10:30:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \ej-webui\src\pages\account\System.vue
-->
<template>
  <div class="production">
    <div class="btns">
      <!-- 检索框 -->
      <el-form :inline="true" :model="params" size="small">
        <el-form-item>
          <el-select clearable v-model="params.type" placeholder="请选择类型">
            <el-option label="收益" value="收益"></el-option>
            <el-option label="提现" value="提现"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select clearable v-model="params.status" placeholder="请选择状态">
            <el-option label="正常" value="正常"></el-option>
            <el-option label="未审核" value="未审核"></el-option>
          </el-select>
        </el-form-item>
        
        <el-form-item>
          <el-select
            v-model="params.id"
            placeholder="顾客编号"
            clearable
          >
            <el-option
              v-for="(item, index) of counts"
              :label="item.name"
              :value="item.id"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-button
          type="primary"
          size="small"
          style="margin-right: 10px"
          @click="pageQueryProductions"
          >查询</el-button
        >
      </el-form>
    </div>
    <div class="content">
      <!-- 表格 -->
      <el-table :data="resData.list" style="width: 100%" size="small">
        <el-table-column label="编号" prop="id"></el-table-column>
        <el-table-column label="交易金额" prop="transferMoney"></el-table-column>
        <el-table-column label="交易时间" prop="transferTime"></el-table-column>
        <el-table-column label="交易类型" prop="type"></el-table-column>
        <el-table-column label="状态" prop="status">
          <template v-slot="scope">
            <el-tag
              v-if="scope.row.status == '正常'"
              size="mini"
              type="success"
              >{{ scope.row.status }}</el-tag
            >
            <el-tag v-else size="mini" type="danger">{{
              scope.row.status
            }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="描述" prop="description"></el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        background
        layout="prev, pager, next, sizes"
        :total="resData.total"
        :page-size="params.pageSize"
        :current-page="params.page"
        @current-change="pageChangeHandler"
        :page-sizes="[5, 10, 15]"
        @size-change="pageSizeChangeHandler"
      >
      </el-pagination>
  </div>
  </div>
</template>
<script>
import requset from "@/utils/request";
import { mapActions } from "vuex";
export default {
  data() {
    return {
      params: {
        page: 1,
        pageSize: 5,
      },
      resData: {},
      counts: [],
      title: "",
      visible: false,
      production: {},
      formLabelWidth: "80px",
    };
  },
  methods: {
    // 导入状态机中的方法
    ...mapActions("count2", ["findAllCounts"]),
    // 分页查询产品表格
    async pageQueryProductions() {
      // 过滤数据将空字符串删除
      for (let key in this.params) {
        if (this.params[key] == "") {
          delete this.params[key];
        }
      }
      let res = await requset.get("/account/pageQuerySystemAccount", {
        params: this.params,
      });
      this.resData = res.data;
    },
    // page改变事件
    pageChangeHandler(page) {
      this.params.page = page;
      this.pageQueryProductions();
    },
    // pageSize改变事件
    pageSizeChangeHandler(pageSize) {
      this.params.pageSize = pageSize;
      this.pageQueryProductions();
    },

  },
  created() {
    this.pageQueryProductions(); // 分页查询产品
    this.findAllCounts().then((res) => {
      this.counts = res.data.list;
    }); // 查询所有账单
  },
};
</script>
<style lang="less" scoped>
</style>